#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int find_biggest(int star, int end, vector<int> &s)
{
  int max_num = 0;
  int index;
  for (int i = 0; i < s.size() - 1; i++)
  {
    if (s[i] >= max_num && i != 0)
    {
      index = i;
    }
  }
  return index;
}

int main()
{
  int N;
  cin >> N;
  vector<int> s(N);
  for (int i = 0; i < N; i++)
  {
    cin >> s[i];
  }

  // 开始找子序列的最大值

  int count = 0;          // 记录修改的次数
  int max_index = 0;      // 记录最大值的索引位置
  int start = 0;          // 记录初始索引
  int end = s.size() - 1; // 记录最后索引
  while (start < end)
  {
    // 找最大值索引
    int max_index = find_biggest(start, end, s);
    for (int i = start; i < max_index; i++)
    {
      if (i > 0 && s[i - 1] < s[max_index])
      {
        s[i - 1] = s[max_index];
        count++;
      }
    }
    start = max_index + 1;
  }
  int sum = 0;
  for (auto i : s)
  {
    sum += s[i];
  }

  cout << count << "  " << sum << endl;

  return 0;
}